package com.example.reagent_management.room.dao

import androidx.paging.PagingSource
import androidx.room.*
import androidx.room.OnConflictStrategy.IGNORE
import com.example.reagent_management.room.entity.ReagentInfoQuery
import com.example.reagent_management.room.entity.ReagentInformation

@Dao
interface ReagentInDao {

    //插入失败策略返回-1并忽略
    @Insert(onConflict = IGNORE)
    fun insertReagentInformation(information: ReagentInformation): Long

    //paging分页数据源
    @Query("select * from reagent_information")
    fun getAllReagent(): PagingSource<Int, ReagentInformation>

    @Query("select project_name,time,type from reagent_information where reagent_id = :id")
    fun getReagentById(id:Long): ReagentInfoQuery

    @Query("delete from reagent_information where reagent_id = :id")
    fun deleteById(id:Long):Int

    @Update(onConflict = OnConflictStrategy.IGNORE)
    fun update(info:ReagentInformation):Int
}